Skip to content

TYP: require _update_inplace gets Frame/Series, never BlockManager #33074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2020

Conversation

jbrockmendel
Copy link
Member

No description provided.

@jbrockmendel jbrockmendel reopened this Mar 27, 2020
@jbrockmendel jbrockmendel changed the title TYP: require _update_inplace gets BlockManager TYP: require _update_inplace gets Frame/Series, never BlockManager Mar 27, 2020
@@ -1505,18 +1504,14 @@ def factorize(self, sort=False, na_sentinel=-1):
def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
return algorithms.searchsorted(self._values, value, side=side, sorter=sorter)

def drop_duplicates(self, keep="first", inplace=False):
inplace = validate_bool_kwarg(inplace, "inplace")
def drop_duplicates(self, keep="first"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only used in Index I think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It exists on Series too

@@ -1809,7 +1805,7 @@ def unique(self):
result = super().unique()
return result

def drop_duplicates(self, keep="first", inplace=False) -> "Series":
def drop_duplicates(self, keep="first", inplace=False) -> Optional["Series"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we actually testing the return value of inplace ops for drop_duplicates / duplciated? IIRC these are actually returning an object (at least they were).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we actually testing the return value of inplace ops for drop_duplicates / duplciated?

Yes, editing this to return self instead of None breaks a test in tests.frame.test_api

@jreback jreback added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Mar 29, 2020
@jreback jreback added this to the 1.1 milestone Mar 30, 2020
@jreback
Copy link
Contributor

jreback commented Mar 30, 2020

ok shouldn't you change the doc-string / annotation of _update_inplace (and maybe add an assertion) to guarantee this?

@jbrockmendel
Copy link
Member Author

and maybe add an assertion

Tricky since we could be dealing with a subclass. I think its pretty clear in context.

@jbrockmendel
Copy link
Member Author

are remaining comments deal-breakers? nice follow-ups to de-duplicate some code after this

@jreback
Copy link
Contributor

jreback commented Apr 1, 2020

no my point on the _update_inplace method should only accept Series/Dataframe and not a BlockManager anymore

i think that’s reasonable to add

@jbrockmendel
Copy link
Member Author

no my point on the _update_inplace method should only accept Series/Dataframe and not a BlockManager anymore

Right, thats what this PR does. The docstring is updated to reflect that. Just havent added an annotation because we dont have a ready-made "same type as self"

@jreback
Copy link
Contributor

jreback commented Apr 1, 2020

k fair enough

maybe an assertion would be good at some point

@jreback jreback merged commit 49bc8d8 into pandas-dev:master Apr 1, 2020
@jbrockmendel jbrockmendel deleted the cln-update_inplace branch April 1, 2020 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants